package com.alpesressources.comexpert.util;

import com.alpesressources.comexpert.bo.adapter.ErrorResponseAdapter;
import com.alpesressources.comexpert.bo.response.ErrorResponse;
import com.alpesressources.comexpert.bo.response.Response;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.apache.log4j.Logger;


public class MyJsonSerializer {
	private static Logger logger = Logger.getLogger(MyJsonSerializer.class);
	
	private Gson gson;
	
	public MyJsonSerializer() {
		GsonBuilder gsonBuilder = new GsonBuilder();
		gsonBuilder.registerTypeAdapter(ErrorResponse.class,
				new ErrorResponseAdapter());
		gsonBuilder.disableHtmlEscaping();
		gson = gsonBuilder.serializeNulls().create();
	}

	public String serialize(Response response) {
		return gson.toJson(response);
	}

}
